package cn.yusei.teamTribe.util;

public class StringUtil {

	private static boolean isNullOrEmpty(String string)
	{
		return string == null || string.equals("");
	}
	
	private static boolean isPositive(String string)
	{
		if(isNullOrEmpty(string))
			return false;
		Integer id = null;
		try
		{
			id = Integer.valueOf(string);
		}
		catch (Exception e)
		{
			return false;
		}
		return id.intValue() > 0;
	}
	
	private static boolean isNumber(String string)
	{
		int len = string.length();
		for(int i=0; i<len; i++)
		{
			char ch = string.charAt(i);
			if(ch < '0' || ch > '9')
				return false;
		}
		return true;
	}
	
	public static boolean haveNullOrEmpty(String ...strings)
	{
		for(String string : strings)
		{
			if(isNullOrEmpty(string))
				return true;
		}
		return false;
	}
	
	public static boolean allPositive(String ...strings)
	{
		for(String string : strings)
		{
			if(!isPositive(string))
				return false;
		}
		return true;
	}
	
	public static boolean lengthAbove(String string, int length)
	{
		return string.length() > length;
	}
	
	public static boolean allNumber(String ...strings)
	{
		for(String string : strings)
		{
			if(!isNumber(string))
				return false;
		}
		return true;
	}
	
}
